/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbravo.pos.inventory.model;

import cn.ekuma.data.dao.I_DataLogic;
import cn.ekuma.data.ui.swing.AbstractRefDTOTableModel;

import com.openbravo.bean.Attribute;
import com.openbravo.bean.AttributeUse;
import com.openbravo.data.basic.BasicException;
import com.openbravo.pos.base.AppLocal;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class AttributeUseTableModel extends AbstractRefDTOTableModel<AttributeUse>{

    public AttributeUseTableModel(I_DataLogic dataLogic) {
        super(dataLogic);
    }

    @Override
    public void initRefMap(Map<Class, List> refObjMap) {
        try {
            refObjMap.put(Attribute.class, dataLogic.list(Attribute.class));
        } catch (BasicException ex) {
            Logger.getLogger(AttributeUseTableModel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public String[] getColumnNames() {
        return new String[]{
          AppLocal.getIntString("label.order"),
          AppLocal.getIntString("Label.Name")
        };
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
       Attribute selectObj=(Attribute) getRefObj(Attribute.class,objs.get(rowIndex).getAttributeID());
       switch(columnIndex){
           case 0:
               return objs.get(rowIndex).getLineNo();
           case 1:
               return selectObj == null ? null :selectObj.getName();
       }
       return null;
    }

}
